package com.lpinfo.spb.plateform.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lpinfo.spb.framework.base.ResponseData;
import com.lpinfo.spb.plateform.system.dto.SysMenuDto;
import com.lpinfo.spb.plateform.system.entity.SysMenu;
import com.lpinfo.spb.plateform.system.service.SysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "菜单管理")
@RestController
@RequestMapping("/menu")
public class SysMenuController {

    @Autowired
    private SysMenuService service;


    @ApiOperation("分页列表")
    @GetMapping("/page")
    public ResponseData page(Page page, SysMenuDto params){
        IPage<SysMenu> result = service.page(page, params);
        return ResponseData.success(result);
    }

    @ApiOperation("保存")
    @PutMapping("/save")
    public ResponseData save(@RequestBody SysMenu params){
        boolean result = service.save(params);
        return ResponseData.success(result);
    }

    @ApiOperation("修改根据主键")
    @PutMapping("/updateById")
    public ResponseData updateById(@RequestBody SysMenu params){
        boolean result = service.updateById(params);
        return ResponseData.success(result);
    }

    @ApiOperation("查询根据主键")
    @GetMapping("/getById/{menuId}")
    public ResponseData getById(@PathVariable("menuId") Long menuId){
        SysMenu result = service.getById(menuId);
        return ResponseData.success(result);
    }


}
